package com.paranoidmonkey.ode;

import java.nio.Buffer;

public class Geom extends ODEObject{

	public Geom(){
		handle=0;
	}
	
	public Geom(int classnum){
		handle=AndrODE.dCreateGeom(classnum);
	}
	
	protected Geom(long handle){
		this.handle=handle;
	}
	
	public void destroy(){
		AndrODE.dGeomDestroy(handle);
	}
	
	public void setEnabled(boolean state){
		if (state){
			AndrODE.dGeomEnable (handle);
		}else{
			AndrODE.dGeomDisable (handle);
		}
	}
	
	public void setData(Object data){
		AndrODE.dGeomSetData (handle, data);
	}
	
	public Object getData(){
		return AndrODE.dGeomGetData (handle);
	}
	
	public void setBody(Body b){
		AndrODE.dGeomSetBody (handle,b.handle);
	}
	
	public Body getBody(){
		return new Body(AndrODE.dGeomGetBody (handle));
	}
	
	public void setPosition( float x, float y, float z){
		AndrODE.dGeomSetPosition (handle, x, y, z);
	}
	public void setPosition   (Vector3 pos){
		AndrODE.dGeomSetPosition   (handle, pos.x(), pos.y(), pos.z());
	}

	public void setRotation(Matrix3 R){
		AndrODE.dGeomSetRotation (handle, R.data);
	}
	
	public void setQuaternion(Quaternion Q){
		AndrODE.dGeomSetQuaternion (handle, Q.data);
	}
	public Vector3 getPosition(){
		return new Vector3(AndrODE.dGeomGetPosition (handle));
	}
	public void copyPosition(Vector3 pos){
		AndrODE.dGeomCopyPosition (handle,pos.data);
	}
	public Matrix3 getRotation(){
		return new Matrix3(AndrODE.dGeomGetRotation (handle));
	}
	public void copyRotation(Matrix3 R){
		AndrODE.dGeomCopyRotation(handle, R.data);
	}
	public void getQuaternion(Quaternion result){
		AndrODE.dGeomGetQuaternion (handle, result.data);
	}
	public Quaternion getQuaternion(){
		Quaternion result=new Quaternion();
		AndrODE.dGeomGetQuaternion (handle, result.data);
		return result;
	}
	public void getAABB(float[] aabb){
		AndrODE.dGeomGetAABB (handle, aabb);
	}
	public void isSpace(){
		AndrODE.dGeomIsSpace (handle);
	}
	public void getSpace(){
		AndrODE.dGeomGetSpace (handle);
	}
	public void getODEClass(){
		AndrODE.dGeomGetClass (handle);
	}
	public void setCategoryBits(long bits){
		AndrODE.dGeomSetCategoryBits (handle,bits);
	}
	public void setCollideBits(long bits){
		AndrODE.dGeomSetCollideBits (handle,bits);
	}
	public long getCategoryBits(){
		return AndrODE.dGeomGetCategoryBits (handle);
	}
	public long getCollideBits(){
		return AndrODE.dGeomGetCollideBits (handle);
	}
	public boolean isEnabled(){
		return (AndrODE.dGeomIsEnabled(handle)!=0);
	}
	public void lowLevelControl(int controlClass, int controlCode, Buffer dataValue, int[] dataSize){
		AndrODE.dGeomLowLevelControl(handle,controlClass,controlCode,dataValue,dataSize);
	}
	public void getRelPointPos(float px, float py, float pz, Vector3 result){
		AndrODE.dGeomGetRelPointPos(handle, px, py, pz, result.data);
	}
	public void getPosRelPoint(float px, float py, float pz, Vector3 result){
		AndrODE.dGeomGetPosRelPoint(handle, px, py, pz, result.data);
	}
	public void vectorToWorld(float px, float py, float pz, Vector3 result){
		AndrODE.dGeomVectorToWorld(handle, px, py, pz, result.data);
	}
	public void vectorFromWorld(float px, float py, float pz, Vector3 result){
		AndrODE.dGeomVectorFromWorld(handle, px, py, pz, result.data);
	}
	public void setOffsetPosition(float x, float y, float z){
		AndrODE.dGeomSetOffsetPosition (handle, x, y, z);
	}
	public void setOffsetRotation(Matrix3 R){
		AndrODE.dGeomSetOffsetRotation (handle, R.data);
	}
	public void setOffsetQuaternion(Quaternion Q){
		AndrODE.dGeomSetOffsetQuaternion (handle,  Q.data);
	}
	public void setOffsetWorldPosition(float x, float y, float z){
		AndrODE.dGeomSetOffsetWorldPosition (handle, x, y, z);
	}
	public void setOffsetWorldRotation(Matrix3 R){
		AndrODE.dGeomSetOffsetWorldRotation (handle,  R.data);
	}
	public void setOffsetWorldQuaternion(Quaternion quaternion){
		AndrODE.dGeomSetOffsetWorldQuaternion(handle, quaternion.data);
	}
	public void clearOffset(){
		AndrODE.dGeomClearOffset(handle);
	}
	public boolean isOffset(){
		return (AndrODE.dGeomIsOffset(handle)!=0);
	}
	public Vector3 getOffsetPosition(){
		return new Vector3(AndrODE.dGeomGetOffsetPosition (handle));
	}
	public void copyOffsetPosition(Vector3 pos){
		AndrODE.dGeomCopyOffsetPosition (handle, pos.data);
	}
	public Matrix3 getOffsetRotation(){
		return new Matrix3(AndrODE.dGeomGetOffsetRotation (handle));
	}
	public void copyOffsetRotation(Matrix3 R){
		AndrODE.dGeomCopyOffsetRotation (handle, R.data);
	}
	public void getOffsetQuaternion(Quaternion result){
		AndrODE.dGeomGetOffsetQuaternion (handle,result.data);
	}
	
	public boolean equals(Object b){
		if (b instanceof Geom) {
			if (((Geom)b).handle==handle){
				return true;
			}
		}
		return false;
	}

}
